@echo off & setlocal enableDelayedExpansion

set /p str=beforeText:

set /p ChangeStr=afterText:

set path=%~dp0

cd /d %path%

for /f "delims=!" %%i in ('dir /aa /b %path%') do (
::echo in progressing %%i_%%j_%%k
set str1=%%i
set str2=!str1:%str%=%ChangeStr%!
echo str1 is !str1! str2 is !str2!
ren "!str1!" "!str2!"
)